﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZenSystemService.Api.Migrations
{
    /// <inheritdoc />
    public partial class ProductTypeDeviceTypeIdForeignKey : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateIndex(
                name: "IX_TrainingItems_DeviceTypeId",
                table: "TrainingItems",
                column: "DeviceTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingItems_InstitutionId",
                table: "TrainingItems",
                column: "InstitutionId");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingItems_ProductTypeId",
                table: "TrainingItems",
                column: "ProductTypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_TrainingItems_DeviceTypes_DeviceTypeId",
                table: "TrainingItems",
                column: "DeviceTypeId",
                principalTable: "DeviceTypes",
                principalColumn: "DeviceTypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_TrainingItems_Institutions_InstitutionId",
                table: "TrainingItems",
                column: "InstitutionId",
                principalTable: "Institutions",
                principalColumn: "InstitutionId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TrainingItems_ProductTypes_ProductTypeId",
                table: "TrainingItems",
                column: "ProductTypeId",
                principalTable: "ProductTypes",
                principalColumn: "ProductTypeId",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_TrainingItems_DeviceTypes_DeviceTypeId",
                table: "TrainingItems");

            migrationBuilder.DropForeignKey(
                name: "FK_TrainingItems_Institutions_InstitutionId",
                table: "TrainingItems");

            migrationBuilder.DropForeignKey(
                name: "FK_TrainingItems_ProductTypes_ProductTypeId",
                table: "TrainingItems");

            migrationBuilder.DropIndex(
                name: "IX_TrainingItems_DeviceTypeId",
                table: "TrainingItems");

            migrationBuilder.DropIndex(
                name: "IX_TrainingItems_InstitutionId",
                table: "TrainingItems");

            migrationBuilder.DropIndex(
                name: "IX_TrainingItems_ProductTypeId",
                table: "TrainingItems");
        }
    }
}
